package biometry;

import java.awt.Dimension;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;

import org.opencv.core.Core;

import com.github.sarxos.webcam.Webcam;



public class Main {

	private static final String WEBCAM_IMAGE_PATH = "webcam.png";
	private static final String GRAYSCALE_IMAGE_PATH = "grayscale.png";
	
	public static void main(String[] args) throws IOException {
		
		System.loadLibrary( Core.NATIVE_LIBRARY_NAME );
		
		takeWebcamImage();
		
		FaceDetector.changeFromColorToGreyscale(new File(WEBCAM_IMAGE_PATH), new File(GRAYSCALE_IMAGE_PATH));
		
//		FaceDetector.detectFace();
//		FaceDetector.detectEyes();
//		FaceDetector.detectNose();
		
	//	FaceDetector.detect();
	}

	private static void takeWebcamImage() throws IOException {
		Webcam webcam = Webcam.getDefault();
	    webcam.setViewSize(new Dimension(1024, 768));
	    webcam.open();
	    BufferedImage image = webcam.getImage();
	    ImageIO.write(image, "PNG", new File(WEBCAM_IMAGE_PATH));
	}

}
